//
//  GoodsPictureHeaderView.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/17.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "GoodsPictureHeaderView.h"
#import "SDCycleScrollView.h"

@interface GoodsPictureHeaderView ()<SDCycleScrollViewDelegate>{
    GLGWLabel * indexNumlabel;
}
@end

@implementation GoodsPictureHeaderView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        // 情景二：采用网络图片实现
        NSArray *imagesURLStrings = @[
                                      @"https://ss2.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/super/whfpf%3D425%2C260%2C50/sign=a4b3d7085dee3d6d2293d48b252b5910/0e2442a7d933c89524cd5cd4d51373f0830200ea.jpg",
                                      @"https://ss0.baidu.com/-Po3dSag_xI4khGko9WTAnF6hhy/super/whfpf%3D425%2C260%2C50/sign=a41eb338dd33c895a62bcb3bb72e47c2/5fdf8db1cb134954a2192ccb524e9258d1094a1e.jpg",
                                      @"http://img.zcool.cn/community/01d881579dc3620000018c1b430c4b.JPG@3000w_1l_2o_100sh.jpg"
                                      ];
        SDCycleScrollView *cycleScrollView2 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, KScreenWidth, self.height) delegate:self placeholderImage:[UIImage imageNamed:@"placeholder"]];
        cycleScrollView2.pageControlStyle = SDCycleScrollViewPageContolStyleNone;
        cycleScrollView2.imageURLStringsGroup = imagesURLStrings;
        cycleScrollView2.delegate = self;
        cycleScrollView2.currentPageDotColor = [UIColor whiteColor]; // 自定义分页控件小圆标颜色
        [self addSubview:cycleScrollView2];
        //
        indexNumlabel = [[GLGWLabel alloc] initWithFont:BOLDSYSTEMFONT(14) theColor:[UIColor whiteColor] inSuperView:self];
        indexNumlabel.layer.cornerRadius = 2.0;
        indexNumlabel.layer.masksToBounds = YES;
        indexNumlabel.backgroundColor = [UIColor colorWithHexString:@"#000000" alpha:0.3];
        [indexNumlabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(19));
            make.bottom.equalTo(self.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(15));
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(30)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(19)));
        }];
        indexNumlabel.textAlignment = NSTextAlignmentCenter;
        indexNumlabel.attributedText = [GLGWLabel bllChangeStr:@"1/3" changewithStr:@"3" changeColoer:[UIColor whiteColor] withFont:SYSTEMFONT(12)];
    }
    return self;
}

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index{
//    DLog(@"第几张图片---------------    %ld",index);
    indexNumlabel.attributedText = [GLGWLabel bllChangeStr:[NSString stringWithFormat:@"%ld/3",index+1] changewithStr:@"3" changeColoer:[UIColor whiteColor] withFont:SYSTEMFONT(12)];
}

@end
